version 13
#delimit ;
set more off ;
set linesize 120;
capture log close; 
log using figure2_code.log, replace;

*************************************************************************;
*  File-Name:  	figure2_code.do						*;
*  Date:	May 31, 2016						*;
*		March 9, 2017 - Run for Replication			*;
*  Author:     	JN (from earlier version by SL)				*;
*  Purpose: 	Graph share of income by Quintile			*;
*		Produce figure2 from Linn and Nagler, APR 2017		*;
*  Data In:	econdata_2013_geoW_D_REP.dta				*;
*  Prev File:	graph_sj_JN3.do						*;
*  Machine:    	Nagler-iMac						*;
*  Status:	Replication Code					*;
*************************************************************************;

*************************************************************************;
* Read in Economic Data		*;
*************************************************************************;

global path "~/dropbox/EconvoteDrop/Replication_APR2017/Graphs_Figure2";

* use ~/Dropbox/EconvoteDrop/Data/Make_econ_quintiles/econdata_2013_geoW_D.dta *;

use econdata_2013_geoW_D_REP.dta;

summarize;

*************************************************************************;
* Graph ESTIMATED shares of family income		*;
*************************************************************************;

twoway (tsline share_q1_est, 
	recast(line)), title(Share of Income - Bottom Quintile) 
	ttitle(Year) subtitle() 
 	legend(order(1 "Bottom Quintile")) 
	ylabel(#3) xlabel(#3)
 	ytitle(Share of Family Income) saving("$path/Q1", replace);
	graph export "$path/Est_Share_of_Income_1952_2012_Q1.pdf", replace;

twoway (tsline share_q2_est, 
	recast(line)), title(Share of Income - Second Quintile) 
	ttitle(Year) subtitle() 
 	legend(order(1 "Quintile Two")) 
	xlabel(#5) ylabel(#3)
 	ytitle(Share of Family Income) saving("$path/Q2", replace);
	graph export "$path/Est_Share_of_Income_1952_2012_Q2.pdf", replace;

twoway (tsline share_q3_est, 
	recast(line)), title(Share of Income - Third Quintile) 
	ttitle(Year) subtitle() 
 	legend(order(1 "Quintile Three")) 
	xlabel(#5) ylabel(#3)
 	ytitle(Share of Family Income) saving("$path/Q3", replace);
	graph export "$path/Est_Share_of_Income_1952_2012_Q3.pdf", replace;

twoway (tsline share_q4_est, 
	recast(line)), title(Share of Income - Fourth Quintile) 
	ttitle(Year) subtitle() 
 	legend(order(1 "Quintile Four")) 
	xlabel(#5) ylabel(#3)
 	ytitle(Share of Family Income) saving("$path/Q4", replace);
	graph export "$path/Est_Share_of_Income_1952_2012_Q4.pdf", replace;

twoway (tsline share_q5_est, 
	recast(line)), title(Share of Income - Top Quintile) 
	ttitle(Year) subtitle() 
 	legend(order(1 "Top Quintile")) 
	xlabel(#5) ylabel(#3)
 	ytitle(Share of Family Income) saving("$path/Q5", replace);
	graph export "$path/Est_Share_of_Income_1952_2012_Q5.pdf", replace;

graph combine "$path/Q1" "$path/Q2" "$path/Q3" "$path/Q4" "$path/Q5" , cols(2);   
graph export "$path/combined_income.pdf", replace; 



log close;

exit;


